x86/vpt: add support for IO-APIC routed interrupts
authorXen Project Security Team <security@xenproject.org>
Tue, 8 May 2018 17:12:10 +0000 (18:12 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 8 May 2018 17:13:13 +0000 (18:13 +0100)
commit14c3f68a57361f20be33ec3848f83d8636a0d34e
treeea0929ccbaa3ed44e6549fed4dc1c316ebac8938
parent75d6828bc2146d0eea16adc92376951a310d94a7
x86/vpt: add support for IO-APIC routed interrupts

And modify the HPET code to make use of it. Currently HPET interrupts
are always treated as ISA and thus injected through the vPIC. This is
wrong because HPET interrupts when not in legacy mode should be
injected from the IO-APIC.

To make things worse, the supported interrupt routing values are set
to [20..23], which clearly falls outside of the ISA range, thus
leading to an ASSERT in debug builds or memory corruption in non-debug
builds because the interrupt injection code will write out of the
bounds of the arch.hvm_domain.vpic array.

Since the HPET interrupt source can change between ISA and IO-APIC
always destroy the timer before changing the mode, or else Xen risks
changing it while the timer is active.

Note that vpt interrupt injection is racy in the sense that the
vIO-APIC RTE entry can be written by the guest in between the call to
pt_irq_masked and hvm_ioapic_assert, or the call to pt_update_irq and
pt_intr_post. Those are not deemed to be security issues, but rather
quirks of the current implementation. In the worse case the guest
might lose interrupts or get multiple interrupt vectors injected for
the same timer source.

This is part of XSA-261.

Address actual and potential compiler warnings. Fix formatting.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/hpet.c
xen/arch/x86/hvm/irq.c
xen/arch/x86/hvm/vpt.c
xen/include/asm-x86/hvm/irq.h
xen/include/asm-x86/hvm/vpt.h